package com.fbd.apipassenger.service;

import com.fbd.apipassenger.remote.ServicePriceClient;
import com.fbd.internalcommon.dto.ForecastPriceDTO;
import com.fbd.internalcommon.dto.ResponseResult;
import com.fbd.internalcommon.response.ForecastPriceResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class ForecastPriceService {

    @Autowired
    private ServicePriceClient servicePriceClient;
    public ResponseResult forecastPrice(ForecastPriceDTO forecastPriceDTO) {

        // 调用计价服务
        ResponseResult<ForecastPriceResponse> forecastPriceResponseResponseResult = servicePriceClient.forecastPrice(forecastPriceDTO);
        ForecastPriceResponse data = forecastPriceResponseResponseResult.getData();
        double price = data.getPrice();
        ForecastPriceResponse forecastPriceResponse = new ForecastPriceResponse();
        forecastPriceResponse.setPrice(price);

        return ResponseResult.success(forecastPriceResponse);
    }
}
